import Vue from 'vue'
import Router from 'vue-router'
import LandlordCertification from '@/framework/pc/views/certification/landlordCertification' //房东认证
import TenantCertification from '@/framework/pc/views/certification/tenantCertification' //租户认证
import Verified from '@/framework/pc/views/certification/verified' //实名认证
import SmallAuthentication from '@/framework/pc/views/smallAuthentication/index' //小额鉴权
import Error from '@/framework/pc/views/error/index' //小额鉴权
Vue.use(Router)

let router = new Router({
	routes: [{
			path: '/tips',
			name: 'Error',
			component: Error
		},
		{
			path: '/landlordCertification',
			name: 'LandlordCertification',
			component: LandlordCertification
		},
		{
			path: '/tenantCertification',
			name: 'TenantCertification',
			component: TenantCertification
		},
		{
			path: '/verified',
			name: 'Verified',
			component: Verified
		},
		{
			path: '/smallAuthentication',
			name: 'SmallAuthentication',
			component: SmallAuthentication
		}
	]
})

/**
 * 判断是否为移动设备，是，则跳转到移动端的路径
 */
router.beforeEach((to, from, next) => {
	if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
		window.location.href = '/m_index.html#/'
		return
	}
	next()
})
router.afterEach((to, from, next) => {
	window.scrollTo(0, 0);
});
export default router
